POV-Ray : Newsgroups : povray.general : Help: Place objects within a circle : Re: Place objects within a circle Server Time
4 Nov 2024 21:24:29 EST (-0500)
  Re: Place objects within a circle  
From: Warp
Date: 12 Sep 2003 05:17:32
Message: <3f618f2c@news.povray.org>
Slime <fak### [at] emailaddress> wrote:
> To counteract this, you need to "pull" the objects closer to the outer edge
> of the circle. The correct way to do this involves calculus (I think), but
> I'm pretty sure that it will turn out that you want to take the square root
> of the X-value you get.

  This is a very good guess.
  The scene below demonstrates that sqrt indeed works very well as a
correcting function.
  The first circle (at the left of the image) uses this method to place
the spheres randomly onto it.
  The second circle (at the right) is for comparison: It uses a bit slower
method to truely distribute spheres randomly onto the circle.
  The difference in distribution evenness is practically none.


camera { location -z*6 look_at 0 angle 35 }
light_source { -z*10, 1 }
#default { pigment { rgb 1 } }

#declare Amount = 1000;
#declare CircleRadius = 1;
#declare SphereRadius = .02;

union
{ #declare S = seed(0);
  #declare Ind = 0;
  #while(Ind < Amount)
    sphere
    { vrotate(x*CircleRadius*sqrt(rand(S)), z*360*rand(S)), SphereRadius
    }
    #declare Ind = Ind+1;
  #end
  disc { 0,-z,CircleRadius pigment { rgb z*.5 } }
  translate -x*CircleRadius
}

union
{ #declare S = seed(0);
  #declare Ind = 0;
  #while(Ind < Amount)
    #declare Loc = <rand(S),rand(S),.5>*2-1;
    #while(vlength(Loc) > 1)
      #declare Loc = <rand(S),rand(S),.5>*2-1;
    #end
    sphere { Loc*CircleRadius, SphereRadius }
    #declare Ind = Ind+1;
  #end
  disc { 0,-z,CircleRadius pigment { rgb z*.5 } }
  translate x*CircleRadius
}


-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.